package {
	import org.flixel.*;
	import flash.net.*;
 
	public class GameOverState extends FlxState {
		public var timer:Number = 0;
		
		public function GameOverState(t:Number) {
			this.timer = t;
			super();
		} 
		
		override public function create():void {
			this.add(new BackgroundImage(0));
			this.add(new BackgroundImage(1));
			this.add(new BackgroundImage(2));
			this.add(new BackgroundImage(3));
			this.add(new FlxSprite(35, 60, LoseImg));
			
			this._timerText = new FlxText(0, FlxG.height - 85, FlxG.width, "")
			this._timerText.text = timer.toFixed();
			this._timerText.alpha = 0.75;
			this._timerText.scrollFactor = new FlxPoint(0, 0);
			this._timerText.setFormat("Nervous", 72, 0xFFFFFFFF, "right");
			this.add(this._timerText);

			FlxG.playMusic(Game.DieMusic);
			this.timer = 0;
			
		}
		
		override public function update():void {
			timer += FlxG.elapsed;
			if (FlxG.keys.justPressed("SPACE") || 
				FlxG.keys.justPressed("ESCAPE") ||
				(FlxG.mouse.justPressed() && this.timer > 2) ||
				this.timer > 10) 
			{
				FlxG.state = new MenuState();
			}
			super.update();
		}
		
		[Embed(source='../content/CouchOnlyLose.png')]
			private var LoseImg:Class;
		//[Embed(source = '../content/CouchMenu.png')] 
		//	private var MenuImg:Class;
		private var _timerText:FlxText;
	}
}